<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!-- 不缓存 -->
  <!-- http 1.0 -->
  <meta http-equiv="pragma" content="no-cache" />
  <!-- http 1.1 -->
  <meta http-equiv="content-type" content="no-cache, must-revalidate" />
  <!-- http 1.0 -->
  <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT" />

  <title>Document</title>
  <link href="https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.12/index.css" rel="stylesheet">
  <!-- Import Vue 3 -->
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.js"></script>
  <!-- Import component library -->
  <script src="https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.12/index.full.min.js"></script>
  <style>
    .box {
      margin: 100px auto;
      width: 200px;
      height: 200px;
      background-color: pink;
      border-radius: 200px;
      color: white;
      text-align: center;
      line-height: 200px;
      font-size: 20px;
      cursor: pointer;
    }
  </style>
</head>

<body>
  <div id="app">
    <div class="box">
      重发授权
    </div>
    <!-- <el-button @click="showMessage">显示消息</el-button> -->
  </div>
  <script>

    const { createApp, ElMessage } = ElementPlus;

    const App = {
      data() {
        return {
          message: "Hello Element Plus",
        };
      },
      methods: {
        showMessage() {
          ElMessage({
            message: '授权成功',
            type: 'success'
          });
        }
      }
    };
    const app = Vue.createApp(App);
    app.use(ElementPlus);
    app.mount("#app");

    document.addEventListener("visibilitychange", () => {
      if (document.visibilityState === "visible") {
        reSendAuth()
        ElMessage({
          message: '授权成功',
          type: 'success'
        });
      }
    })

    document.querySelector(".box").addEventListener("click", () => {
      reSendAuth()
      // window.alert('重发授权')
      ElMessage({
        message: '授权成功',
        type: 'success'
      });
    })
    const reSendAuth = () => {
      var myHeaders = new Headers();
      myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
      myHeaders.append("Origin", "https://wcg2c.sms.huhutv.com.cn")

      var requestOptions = {
        method: 'POST',
        headers: myHeaders,
        redirect: 'follow',
        body: JSON.stringify({ "authValue": "001255850438", "tenancyCode": "003", "channelCode": "0302", "appKey": "100001" })
      };

      fetch("https://wcg2c.sms.huhutv.com.cn/server-run/ws/rest/User/noLoginCheckCard", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));



      var myHeaders = new Headers();
      myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");

      var requestOptions = {
        method: 'POST',
        headers: myHeaders,
        redirect: 'follow',
        body: JSON.stringify({
          "authValue": "001255850438",
          "openId": "ou8mqjrpvFD_H0B2VVHmhI6qBI2w",
          "sysUserCode": "",
          "mobilePhone": "",
          "loginToken": "",
          "upMobilePhone": "",
          "latitude": "25.806718",
          "longitude": "112.203084",
          "tenancyCode": "003",
          "channelCode": "0302",
          "appKey": "100001"
        })
      };

      fetch("https://wcg2c.sms.huhutv.com.cn/server-run/ws/rest/User/noLoginAuthService", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));
    }
  </script>
</body>

</html>